using System;
using System.Collections.Generic;
using System.Text;

namespace csammisrun.OscarLib.Utility
{
  /// <summary>
  /// This is not a real connection
  /// </summary>
  class ChatInvitationConnection : DirectConnection
  {
    #region Chat room invitation caching
    private static List<string> _chatroomcache = new List<string>();
    public static void CacheChatRoomCreation(string roomname, ushort exchange)
    {
      _chatroomcache.Add(roomname + exchange.ToString());
    }

    public static bool IsExplictChatCreation(string roomname, ushort exchange)
    {
      string cache = roomname + exchange.ToString();
      bool retval = _chatroomcache.Contains(cache);
      _chatroomcache.Remove(cache);
      return retval;
    }
    #endregion

    public ChatInvitation ChatInvite = null;
    public ChatRoomInfo ChatRoom = null;

    public ChatInvitationConnection(Session parent, int id, DirectConnectRole role)
      : base(parent, id, DirectConnectionMethod.Direct, role)
    {
    }
  }

  /// <summary>
  /// Encapsulates a connection to an OSCAR chat room
  /// </summary>
  class ChatConnection : Connection
  {
    private ChatRoomInfo _roominfo;

    /// <summary>
    /// Creates a new chat connection
    /// </summary>
    /// <param name="parent">The <see cref="Session"/> that owns this connection</param>
    /// <param name="id">The connection's unique ID</param>
    /// <param name="roominfo">A <see cref="ChatRoomInfo"/> object</param>
    public ChatConnection(Session parent, int id, ChatRoomInfo roominfo)
      : base(parent, id)
    {
      _roominfo = roominfo;
    }

    public ChatRoomInfo RoomInfo
    {
      get { return _roominfo; }
    }
  }
}
